February 5, 2006
CK JAVA DEFENSIVE
PROGMONJavaCDefensive
CONDITIONS JAVA JDK 1.5 simulated in  ADA
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

-- dining philosophers paradigm. 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-- The chopsticks are allocated as many as available 
-- and the allocation is completed as soon as the missing chopsticks are released.
-- allocates two sticks if they are available
-- else allocate left stick if possible 
-- waits if both sticks have not been allocated
 
-- JAVA implementation with Lock and conditions of J2SE/JDK 1.5
-- condition synchronisation provided by additional condition objects
-- Solution when a monitor allows several named condition variable

-- simulated with an Ada protected object 
--    which simulates Java concurrency semantics
-- the Java condition.await operation is here an entry call with a barrier
-- one Java synchronized method simulated by Get_LR  and condition entries

-- instrumented for concurrency denials ratio measurement

-- ********    reliable, deadlock free
-- ****************************************************************

*****   DINING PHILOSOPHERS WITH STICK ALLOCATION AS MANY AS AVAILABLE
*****   RELIABLE JAVA JDK 1.5  CONDITION OBJECTS SOLUTION : SIMULATED IN ADA
*****   WITH CONCURRENCY RATIO INSTRUMENTATION
 5 philosophers thinking 0.010000000 and eating 0.010000000
 and (when Java monitor semantics) requesting 0.000000000
                 CONCURRENCY MEASURES DISPLAY
 NbMealsAttended =   100000
 NbPairs :  39809
 NbRequestSingletons :  60191
 NbStructuralRefusals :  45109
 NbCautiousRefusals :  28019
 Total number of denials =   73128
      Total simulation time is    437.335166000
      Mean allocation time is     218.358202000
      Allocation ratio is         0.499292576
      Philosopher  0  remains hungry during  218.559536000
      Philosopher  1  remains hungry during  218.419921000
      Philosopher  2  remains hungry during  219.958309000
      Philosopher  3  remains hungry during  217.557322000
      Philosopher  4  remains hungry during  217.295922000

real    7m17.496s
user    0m14.250s
sys     0m6.030s

***************************************************************
Ordinateur-de-pacha:~ claudePB$ time ./diner*****   DINING PHILOSOPHERS WITH STICK ALLOCATION AS MANY AS AVAILABLE
*****   RELIABLE JAVA JDK 1.5  CONDITION OBJECTS SOLUTION : SIMULATED IN ADA
*****   WITH CONCURRENCY RATIO INSTRUMENTATION
 5 philosophers thinking 0.010000000 and eating 0.010000000
 and (when Java monitor semantics) requesting 0.000000000
                 CONCURRENCY MEASURES DISPLAY
 NbMealsAttended =   100000
 NbPairs :  39891
 NbRequestSingletons :  60109
 NbStructuralRefusals :  45227
 NbCautiousRefusals :  27704
 Total number of denials =   72931
      Total simulation time is    437.171592000
      Mean allocation time is     218.439799600
      Allocation ratio is         0.499666043
      Philosopher  0  remains hungry during  218.758708000
      Philosopher  1  remains hungry during  218.011951000
      Philosopher  2  remains hungry during  219.252336000
      Philosopher  3  remains hungry during  218.859186000
      Philosopher  4  remains hungry during  217.316817000

real    7m17.361s
user    0m14.260s
sys     0m5.850s